package com.itheima.text3;

public class SellTicket implements Runnable {
    int ticket = 1;


    @Override
    public void run() {
        while (true) {
            synchronized (SellTicket.class) {
                if (ticket > 100) {
                    break;
                } else {
                    System.out.println(Thread.currentThread().getName() + "正在出售第" + ticket + "张票");
                    try {
                        Thread.sleep(100);
                    } catch (InterruptedException e) {
                        e.printStackTrace();
                    }
                    ticket++;
                }
            }
        }
    }
}